package com.hzit.mmcb.core.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hzit.mmcb.core.pojo.dto.BorrowerAttachDTO;
import com.hzit.mmcb.core.pojo.entity.BorrowerAttach;
import com.hzit.mmcb.core.mapper.BorrowerAttachMapper;
import com.hzit.mmcb.core.service.BorrowerAttachService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 借款人上传资源表 服务实现类
 * </p>
 *
 * @author ljh
 * @since 2024-08-27
 */
@Service
public class BorrowerAttachServiceImpl extends ServiceImpl<BorrowerAttachMapper, BorrowerAttach> implements BorrowerAttachService {

    @Override
    public List<BorrowerAttachDTO> getborrowerAttachDTOList(Integer id) {
        LambdaQueryWrapper<BorrowerAttach> lambdaQueryWrapper=new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(BorrowerAttach::getBorrowerId,id);
        List<BorrowerAttachDTO> borrowerAttachDTOList=new ArrayList<>();
        List<BorrowerAttach> list = this.list(lambdaQueryWrapper);
        list.forEach(borrowerAttach->{
            BorrowerAttachDTO borrowerAttachVO = new BorrowerAttachDTO();
            borrowerAttachVO.setImageType(borrowerAttach.getImageType());
            borrowerAttachVO.setImageUrl(borrowerAttach.getImageUrl());
            borrowerAttachDTOList.add(borrowerAttachVO);
        });
        return borrowerAttachDTOList;
    }
}
